import { onMounted, onBeforeUnmount, ref } from 'vue'
export  function SrollTopShow(){
    const y = ref(0)
function scrollEvent () {
  // 获取到滚动的y值
  y.value =
    document.documentElement.scrollTop ||
    document.body.scrollTop ||
    window.pageYOffset
}
onMounted(() => {
  // 添加滚动监听事件
  window.addEventListener('scroll', scrollEvent)
})
onBeforeUnmount(() => {
  // 移除滚动监听事件
  window.removeEventListener('scroll', scrollEvent)
})
return y
}